home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / System / Sample 2.4 Think C distribution / misc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-26  |  17.7 KB  |  656 lines  |  [TEXT/KAHL]

  1. /*______________________________________________________________________
  2.  
  3.     misc.c - Miscellany Module
  4.     
  5.     Copyright © 1988, 1989, 1990 Northwestern University.  Permission is granted
  6.     to use this code in your own projects, provided you give credit to both
  7.     John Norstad and Northwestern University in your about box or document.
  8.     
  9.     This module takes care of various miscellaneous tasks.
  10. _____________________________________________________________________*/
  11.  
  12. #include <string.h>
  13.  
  14. #include "utl.h"
  15. #include "scn.h"
  16. #include "vol.h"
  17. #include "rep.h"
  18. #include "rez.h"
  19. #include "glob.h"
  20. #include "mssg.h"
  21. #include "wstm.h"
  22. #include "unmount.h"
  23. #include "misc.h"
  24. #include "prog.h"
  25. #include "main.h"
  26.  
  27. #define nil 0
  28.  
  29. /*______________________________________________________________________
  30.  
  31.     misc_HiliteScan - Hilite Scan Button.
  32.     
  33.     Exit:    Scan button hilited iff there is a current
  34.             volume.
  35. _____________________________________________________________________*/
  36.  
  37.  
  38. void misc_HiliteScan(void)
  39.  
  40. {
  41.     short            vRefNum;                /* ref num of selected vol */
  42.     short            hiliteVal;            /* 0 to hilite, 255 to unhilite */
  43.     
  44.     main_SetPort();
  45.     hiliteVal = (vol_GetSel(&vRefNum) == nsvErr) ? 255 : 0;
  46.     HiliteControl(Controls[scanID-firstControl], hiliteVal);
  47. }
  48.  
  49. /*______________________________________________________________________
  50.  
  51.     misc_ClearReport - Clear the Report.
  52. _____________________________________________________________________*/
  53.  
  54.  
  55. void misc_ClearReport (void)
  56.  
  57. {
  58.     Rect                inval;            /* rect to be invalidated */
  59.  
  60.     main_SetPort();
  61.     rep_Clear(Report);
  62.     rep_Fill(Report, repHeadID, false);
  63.     rep_GetRect(Report, &inval);
  64.     InsetRect(&inval, 1, 1);
  65.     InvalRect(&inval);
  66.     mssg_ClearTags();
  67. };
  68.  
  69. /*______________________________________________________________________
  70.  
  71.     LoadAll - Load all Sample Resources of a Given Type
  72.     
  73.     Entry:        rType = resource type.
  74.                     firstID = first resource ID.
  75.                     lastID = last resource ID.
  76. _____________________________________________________________________*/
  77.  
  78.  
  79. static void LoadAll (OSType rType, short firstID, short lastID)
  80.  
  81. {
  82.     short                i;                /* loop index */
  83.     short                n;                /* number of resources of type */
  84.     Handle            h;                /* handle to resource */
  85.     short                theID;        /* resource id */
  86.     ResType            theType;        /* resource type */
  87.     Str255            name;            /* resource name */
  88.     
  89.     n = CountResources(rType);
  90.     SetResLoad(false);
  91.     for (i = 1; i <= n; i++) {
  92.         h = GetIndResource(rType, i);
  93.         if (!*h && HomeResFile(h) == DfectRefNum) {
  94.             GetResInfo(h, &theID, &theType, name);
  95.             if (firstID <= theID && theID <= lastID) LoadResource(h);
  96.         };
  97.     };
  98.     SetResLoad(true);
  99. }
  100.  
  101. /*______________________________________________________________________
  102.  
  103.     misc_CheckEject - Check for Eject of System or Sample Volume
  104.     
  105.     Entry:        refNum = vol ref num or drive num of volume about
  106.                         to be ejected.
  107.                         
  108.     If the system volume or Sample's volume is about to be ejected, 
  109.     this routine loads all the resources which might be needed from the system 
  110.     file or from the Sample file.
  111. _____________________________________________________________________*/
  112.  
  113.  
  114. void misc_CheckEject (short refNum)
  115.  
  116. {
  117.     Handle                h;                /* handle to resource */
  118.     short                    vRefNum;        /* vol ref num */
  119.     Str255                volName;        /* vol name */
  120.     long                    freeBytes;    /* free bytes on vol */
  121.     Handle                hdlog;        /* handle to please wait dialog template */
  122.     DialogPtr            dlog;            /* pointer to please wait dialog */
  123.     Boolean                memTight;    /* true if < 300K free memory */
  124.     static Boolean        firstTimeD=true;    /* true if haven't preloaded Sample
  125.                                                         resources yet */
  126.     static Boolean        firstTimeS=true;    /* true if haven't preloaded System
  127.                                                         resources yet */
  128.  
  129.     /* Convert a drive number to a vol ref number. */
  130.     
  131.     if (refNum > 0) {
  132.         (void) GetVInfo(refNum, volName, &vRefNum, &freeBytes);
  133.     } else {
  134.         vRefNum = refNum;
  135.     };
  136.  
  137.     /* Put up "Please wait" dialog if we need to load resources for 
  138.         the first time. */
  139.  
  140.     dlog = nil;
  141.     if ((vRefNum == SysVol && firstTimeS) || 
  142.         (vRefNum == DfectVol && firstTimeD)) {
  143.         SetCursor(*Watch);
  144.         hdlog = GetResource('DLOG', plsWaitID);
  145.         HNoPurge(hdlog);
  146.         utl_CenterDlogRect(*(Rect**)hdlog, false);
  147.         dlog = GetNewDialog(plsWaitID, nil, (WindowPtr)-1);
  148.         ShowWindow((WindowPtr)dlog);
  149.         DrawDialog(dlog);
  150.         if (vRefNum == SysVol) {
  151.             firstTimeS = false;
  152.         } else {
  153.             firstTimeD = false;
  154.         };
  155.     } else {
  156.         return;
  157.     };
  158.         
  159.     /* If ejecting Sample volume, load Sample resources that 
  160.         we might need later.  If memory is tight (<300K free memory), then
  161.         we don't preload the Help window resources. */
  162.     
  163.     if (vRefNum == DfectVol) {
  164.         memTight = FreeMem() < 300000;
  165.         if (memTight) {
  166.             LoadAll('PICT', 128, 199);
  167.             LoadAll('STR#', 128, 199);
  168.         } else {
  169.             LoadAll('PICT', 0, 9999);
  170.             LoadAll('STR#', 0, 9999);
  171.             LoadAll('TCON', 0, 9999);
  172.             LoadAll('TAG ', 0, 9999);
  173.             LoadAll('CELL', 0, 9999);
  174.             LoadAll('LDEF', 0, 9999);
  175.         };
  176.         LoadAll('WIND', 0, 9999);
  177.         LoadAll('CNTL', 0, 9999);
  178.         LoadAll('ALRT', 0, 9999);
  179.         LoadAll('DITL', 0, 9999);
  180.         LoadAll('DLOG', 0, 9999);
  181.         LoadAll('SICN', 0, 9999);
  182.         LoadAll('CURS', 0, 9999);
  183.         LoadAll('CODE', 0, 9999);
  184.         LoadAll('CREA', 0, 9999);
  185.         LoadAll('MENU', 0, 9999);
  186.     };
  187.     
  188.     /* If ejecting System volume, load system resources that we
  189.         might need later. */
  190.  
  191.     if (vRefNum == SysVol) {
  192.         (void) utl_CheckPack(listMgr, true);
  193.         (void) utl_CheckPack(stdFile, true);
  194.         (void) utl_CheckPack(dskInit, true);
  195.         (void) utl_CheckPack(intUtil, true);
  196.         (void) utl_CheckPack(bdConv, true);
  197.         CouldDialog(putDlgID);
  198.         CouldAlert(sfNoPrivs);
  199.         CouldAlert(sfBadChar);
  200.         CouldAlert(sfSysErr);
  201.         CouldAlert(sfReplaceExisting);
  202.         CouldAlert(sfDiskLocked);
  203.         utl_DILoad();
  204.         h = GetResource('MBDF', 0);
  205.         h = GetResource('MDEF', 0);
  206.         h = GetResource('itl0', 0);
  207.         h = GetResource('ICON', stopIcon);
  208.         h = GetResource('ICON', noteIcon);
  209.         h = GetResource('INTL', 0);
  210.         /* call SysBeep to force snd and snth resources to be loaded. */
  211.         SysBeep(beepDuration);
  212.     };
  213.     
  214.     /* Dispose of please wait dialog. */
  215.     
  216.     if (dlog) {
  217.         DisposDialog(dlog);
  218.         HPurge(hdlog);
  219.     };
  220.     
  221.     misc_SetCursor();
  222. }
  223.     
  224. /*______________________________________________________________________
  225.  
  226.     misc_ValPrint - Validate Print Record.
  227.     
  228.     Entry:    p = pointer to rpp param block.
  229.                 p->hPrint = pointer to print record, or nil if none
  230.                     yet allocated.
  231.                 report = true if this is for a report printing operation.
  232.                 report = false if this is for a document printing operation.
  233.     
  234.     Exit:        p->hPrint = pointer to print record.  A new one is allocated
  235.                     if necessary, and any existing one is validated.
  236.                     
  237.                 If a new print record is allocated, or if the existing one
  238.                 was invalid, then the other fields in the rpp param block
  239.                 are also initialized.  The initial values depend on whether
  240.                 this is a report or document being printed, and whether
  241.                 the output device is a LaserWriter or ImageWriter.
  242. _____________________________________________________________________*/
  243.  
  244.  
  245. void misc_ValPrint (rpp_PrtBlock *p, Boolean report)
  246.  
  247. {
  248.     Boolean                setDefaults;    /* true to set default values */
  249.     Boolean                laser;            /* true if laserwriter */
  250.     char                    *defFont1;        /* pointer to first default font name */
  251.     char                    *defFont2;        /* pointer to second default font name */
  252.     short                    defSize1;        /* first default size */
  253.     short                    defSize2;        /* second default size */
  254.  
  255.     setDefaults = true;
  256.     if (p->hPrint) {
  257.         setDefaults = PrValidate(p->hPrint);
  258.     } else {
  259.         p->hPrint = (THPrint)NewHandle(sizeof(TPrint));
  260.         PrintDefault(p->hPrint);
  261.         defSize1 = (**(p->hPrint)).prInfo.iVRes;
  262.     };
  263.     if (setDefaults) {
  264.         laser = utl_IsLaser(p->hPrint);
  265.         if (report) {
  266.             if (laser) {
  267.                 defFont1 = defFont2 = "\pHelvetica";
  268.             } else {
  269.                 defFont1 = defFont2 = "\pGeneva";
  270.             };
  271.             defSize1 = defSize2 = 10;
  272.         } else {
  273.             if (laser) {
  274.                 defFont1 = "\pPalatino";
  275.                 defSize1 = 10;
  276.                 defFont2 = "\pTimes";
  277.                 defSize2 = 12;
  278.             } else {
  279.                 defFont1 = defFont2 = "\pGeneva";
  280.                 defSize1 = defSize2 = 10;
  281.             };
  282.         };
  283.         p->reverseOrder = laser ? true : false;
  284.         if (utl_GetFontNumber((Str255 *)defFont1, &p->fontNum)) {
  285.             p->fontSize = defSize1;
  286.         } else if (utl_GetFontNumber((Str255 *)defFont2, &p->fontNum)) {
  287.             p->fontSize = defSize2;
  288.         } else {
  289.             p->fontNum = applFont;
  290.             p->fontSize = defSize1;
  291.         };
  292.         p->topMargin = p->botMargin = 50;
  293.         p->leftMargin = p->rightMargin = 100;
  294.     };
  295.     p->header = true;
  296.     p->titleSep = report ? 25 : 40;
  297.     p->titleFont = p->fontNum;
  298.     p->titleStyle = bold;
  299.     p->titleSize = 90;
  300.     p->dlogID = prDlogID;
  301.     p->tabConID = tconID;
  302.     p->emptyPageRangeID = noPagesID;
  303.     p->ditlID = pageSetupID;
  304.     p->sizeRangeID = illegalSizeID;
  305.     p->marginsTooBigID = marTooBigID;
  306.     p->truncateRightID = truncRightID;
  307.     p->truncateBottomID = truncBottomID;
  308.     p->minFontSize = 1;
  309.     p->maxFontSize = 24;
  310.     p->updateAll = misc_Update;
  311. }
  312.  
  313. /*______________________________________________________________________
  314.  
  315.     misc_ReadPref - Read the Preferences File.
  316. _____________________________________________________________________*/
  317.  
  318.  
  319. void misc_ReadPref (void)
  320.  
  321. {
  322.     ParamBlockRec        pBlockMFS;        /* param block for PBSetVol call */
  323.     WDPBRec                pBlockHFS;        /* param block for PBHSetVol call */
  324.     Str255                fName;            /* "Sample Prefs" file name */
  325.     OSErr                    rCode;            /* result code */
  326.     short                    refNum;            /* resource file refnum */
  327.     Boolean                error;            /* true if error encountered */
  328.     char                    version[30];    /* version number */
  329.     Handle                thePrefs;        /* handle to prefs resource */
  330.     Boolean                sane;                /* true if prefs resource fork is sane */
  331.     
  332.     /* Set the default volume and directory to the system volume and the
  333.         blessed folder. */
  334.     
  335.     if (utl_VolIsMFS(SysVol)) {
  336.         pBlockMFS.volumeParam.ioNamePtr = nil;
  337.         pBlockMFS.volumeParam.ioVRefNum = SysVol;
  338.         rCode = PBSetVol(&pBlockMFS, false);
  339.     } else {
  340.         pBlockHFS.ioNamePtr = nil;
  341.         pBlockHFS.ioVRefNum = SysVol;
  342.         pBlockHFS.ioWDDirID = SysDirID;
  343.         rCode = PBHSetVol((WDPBPtr)&pBlockHFS, false);
  344.     };
  345.     error = rCode;
  346.     
  347.     /* Open the "Sample Prefs" resource file with read-only permission. */
  348.     
  349.     refNum = -1;
  350.     if (!error) {
  351.         GetIndString(fName, strListID, prefsFileName);
  352.         if (utl_RFSanity(&fName, &sane) || !sane) {
  353.             error = true;
  354.             utl_StopAlert(prefsBadID, nil, 0);
  355.             FSDelete(fName, 0);
  356.         };
  357.         if (OldRom) {
  358.             refNum = OpenResFile(fName);
  359.         } else {
  360.             refNum = OpenRFPerm(fName, 0, fsRdPerm);
  361.         };
  362.         error = refNum == -1;
  363.     };
  364.     
  365.     /* Load the prefs resource. */
  366.     
  367.     if (!error) {
  368.         thePrefs = GetResource('DPRF', 0);
  369.         error = !thePrefs;
  370.     };
  371.     
  372.     /* Check for the proper size of the resource. */
  373.     
  374.     if (!error) error = GetHandleSize(thePrefs) != sizeof(Prefs);
  375.     
  376.     /* Copy the contents of the prefs resource to the global Prefs variable. */
  377.     
  378.     if (!error) memcpy(&Prefs, *thePrefs, sizeof(Prefs));
  379.     
  380.     /* Check the version number. */
  381.     
  382.     if (!error) {
  383.         GetIndString((StringPtr)version, strListID, prefsVersStr);
  384.         error = !EqualString((StringPtr)version, (StringPtr)Prefs.version, false, false);
  385.     };
  386.     
  387.     /* Copy the print records into relocatable blocks, and store handles
  388.         to them in the print blocks. */
  389.         
  390.     if (!error && Prefs.mainPrint.hPrint)
  391.         error = PtrToHand((Ptr)&Prefs.mainPrintRec, 
  392.             (Handle*)&Prefs.mainPrint.hPrint,
  393.             sizeof(TPrint));
  394.     if (!error && Prefs.helpPrint.hPrint)
  395.         error = PtrToHand((Ptr)&Prefs.helpPrintRec, 
  396.             (Handle*)&Prefs.helpPrint.hPrint,
  397.             sizeof(TPrint));
  398.     
  399.     /* If any error was encountered, initialize the Prefs global variable to
  400.         default values. */
  401.         
  402.     if (error) {
  403.         GetIndString((StringPtr)Prefs.version, strListID, prefsVersStr);
  404.         wstm_Init(&Prefs.mainState);
  405.         wstm_Init(&Prefs.helpState);
  406.         wstm_Init(&Prefs.prefState);
  407.         wstm_Init(&Prefs.abouState);
  408.         Prefs.mainPrint.hPrint = nil;
  409.         Prefs.helpPrint.hPrint = nil;
  410.         Prefs.numOpenWind = 1;
  411.         Prefs.openWind[0] = mainWind;
  412.         Prefs.helpScrollPos = 0;
  413.         Prefs.beepCount = 0;
  414.         Prefs.scanningStation = false;
  415.         Prefs.scanningStationOp = checkOp;
  416.         Prefs.repCreator = 'ttxt';
  417.         Prefs.docCreator = 'MSWD';
  418.         Prefs.repOtherCre = '????';
  419.         Prefs.docOtherCre = '????';
  420.         Prefs.notifOption = notifIcon;
  421.     };
  422.     
  423.     /* Close the resource file. */
  424.     
  425.     if (refNum != -1) CloseResFile(refNum);
  426. }
  427.  
  428. /*______________________________________________________________________
  429.  
  430.     misc_WritePref - Write the Preferences File.
  431. _____________________________________________________________________*/
  432.  
  433.  
  434. void misc_WritePref (void)
  435.  
  436. {
  437.     ParamBlockRec        pBlockMFS;        /* param block for PBSetVol call */
  438.     WDPBRec                pBlockHFS;        /* param block for PBHSetVol call */
  439.     Str255                fName;            /* "Sample Prefs" file name */
  440.     OSErr                    rCode;            /* result code */
  441.     short                    refNum;            /* resource file refnum */
  442.     Boolean                error;            /* true if error encountered */
  443.     FInfo                    fndrInfo;        /* Finder info */
  444.     Handle                thePrefs;        /* handle to prefs resource */
  445.     short                    numOpenWind;    /* number of open windows */
  446.     WindowPtr            curWind;            /* ptr to cur window */
  447.     WindowObject        *curObj;            /* ptr to cur window object */
  448.     WindowPtr            nextWind;        /* ptr to next window */
  449.     WindKind                windKind;        /* window kind */
  450.     
  451.     /* Walk the window list.  Close all windows, and save the open window
  452.         states and orders in the Prefs variable. */
  453.         
  454.     numOpenWind = 0;
  455.     curWind = FrontWindow();
  456.     while (curWind) {
  457.         nextWind = (WindowPtr)((WindowPeek)curWind)->nextWindow;
  458.         windKind = misc_GetWindKind(curWind);
  459.         if (windKind != daWind) {
  460.             Prefs.openWind[numOpenWind] = windKind;
  461.             numOpenWind++;
  462.             curObj = (WindowObject*)((WindowPeek)curWind)->refCon;
  463.             (*curObj->close)();
  464.         };
  465.         curWind = nextWind;
  466.     };
  467.     Prefs.numOpenWind = numOpenWind;
  468.     
  469.     /* Copy the print records into the Prefs variable. */
  470.     
  471.     if (Prefs.mainPrint.hPrint) 
  472.         memcpy(&Prefs.mainPrintRec, *Prefs.mainPrint.hPrint, sizeof(TPrint));
  473.     if (Prefs.helpPrint.hPrint)
  474.         memcpy(&Prefs.helpPrintRec, *Prefs.helpPrint.hPrint, sizeof(TPrint));
  475.     
  476.     /* Set the default volume and directory to the system volume and the
  477.         blessed folder. */
  478.     
  479.     if (utl_VolIsMFS(SysVol)) {
  480.         pBlockMFS.volumeParam.ioNamePtr = nil;
  481.         pBlockMFS.volumeParam.ioVRefNum = SysVol;
  482.         rCode = PBSetVol(&pBlockMFS, false);
  483.     } else {
  484.         pBlockHFS.ioNamePtr = nil;
  485.         pBlockHFS.ioVRefNum = SysVol;
  486.         pBlockHFS.ioWDDirID = SysDirID;
  487.         rCode = PBHSetVol((WDPBPtr)&pBlockHFS, false);
  488.     };
  489.     error = rCode;
  490.     
  491.     /* Open the "Sample Prefs" resource file with read/write permission.
  492.         If it doesn't exist, create it with type D2C1 and creator D2CT. */
  493.     
  494.     refNum = -1;
  495.     if (!error) {
  496.         GetIndString(fName, strListID, prefsFileName);
  497.         if (OldRom) {
  498.             refNum = OpenResFile(fName);
  499.         } else {
  500.             refNum = OpenRFPerm(fName, 0, fsRdWrPerm);
  501.         };
  502.         if (refNum == -1) {
  503.             CreateResFile(fName);
  504.             if (!(error = ResError())) {
  505.                 if (!(error = GetFInfo(fName, 0, &fndrInfo))) {
  506.                     fndrInfo.fdType = 'D2C1';
  507.                     fndrInfo.fdCreator = 'D2CT';
  508.                     if (!(error = SetFInfo(fName, 0, &fndrInfo))) {
  509.                         if (OldRom) {
  510.                             refNum = OpenResFile(fName);
  511.                         } else {
  512.                             refNum = OpenRFPerm(fName, 0, fsRdWrPerm);
  513.                         };
  514.                         error = refNum == -1;
  515.                     };
  516.                 };
  517.             };
  518.         };
  519.     };
  520.     
  521.     /* Load the prefs resource.  If no such resource exists, create one. */
  522.     
  523.     if (!error) {
  524.         thePrefs = GetResource('DPRF', 0);
  525.         if (!thePrefs) {
  526.             thePrefs = NewHandle(sizeof(Prefs));
  527.             AddResource((Handle)thePrefs, (ResType)'DPRF', 0, (StringPtr)"\p");
  528.             error = ResError();
  529.         };
  530.     };
  531.     
  532.     /* Set the proper size of the resource and copy the Prefs global variable
  533.         to the resource. */
  534.     
  535.     if (!error) error = PtrToXHand((Ptr)&Prefs, thePrefs, sizeof(Prefs));
  536.     
  537.     /* Mark the resource changed. */
  538.     
  539.     if (!error) ChangedResource(thePrefs);
  540.     
  541.     /* Close the resource file. */
  542.     
  543.     if (refNum != -1) CloseResFile(refNum);
  544. }
  545.  
  546. /*______________________________________________________________________
  547.  
  548.     misc_GetWindKind - Get Window Kind.
  549.     
  550.     Entry:    theWindow = pointer to window.
  551.     
  552.     Exit:        function result = window kind.
  553. _____________________________________________________________________*/
  554.  
  555.  
  556. WindKind misc_GetWindKind (WindowPtr theWindow)
  557.  
  558. {
  559.     return utl_IsDAWindow(theWindow) ?
  560.         daWind :
  561.         ((WindowObject*)((WindowPeek)theWindow)->refCon)->windKind;
  562. }
  563.  
  564. /*______________________________________________________________________
  565.  
  566.     misc_Notify - Notify User.
  567.     
  568.     Entry:    msg = index in STR# resource of message.
  569.                 wait = true to wait until brought to foreground.
  570. _____________________________________________________________________*/
  571.  
  572.  
  573. void misc_Notify (short msg, Boolean wait)
  574.  
  575. {
  576.     if (InForeground) return;
  577.     if (utl_SysHasNotMgr && !Notified) {
  578.         Notified = true;
  579.         NotifRec.qType = nmType;
  580.         NotifRec.nmMark = 1;
  581.         NotifRec.nmSIcon = Prefs.notifOption == notifDiamond ? nil : 
  582.             GetResource('SICN', smallDfectIconID);
  583.         if (Prefs.notifOption == notifAlert) {
  584.             NotifRec.nmSound = (Handle)-1;
  585.             NotifRec.nmStr = NotifString;
  586.             GetIndString(NotifString, strListID, msg);
  587.             NotifRec.nmResp = (ProcPtr)-1;
  588.         } else {
  589.             NotifRec.nmSound = nil;
  590.             NotifRec.nmStr = nil;
  591.             NotifRec.nmResp = nil;
  592.         };
  593.         NMInstall((QElemPtr)&NotifRec);
  594.     };
  595.     if (!wait) return;
  596.     while (!InForeground) prog_Event();
  597. }
  598.  
  599. /*______________________________________________________________________
  600.  
  601.     misc_Update - Process All Pending Update Events.
  602. _____________________________________________________________________*/
  603.  
  604.  
  605. void misc_Update (void)
  606.  
  607. {
  608.     EventRecord            event;
  609.  
  610.     while (EventAvail(updateMask, &event)) prog_Event();
  611. }
  612.  
  613. /*______________________________________________________________________
  614.  
  615.     misc_PrintError - Handle Printing Error.
  616. _____________________________________________________________________*/
  617.  
  618.  
  619. void misc_PrintError (OSErr rCode)
  620.  
  621. {
  622.     Str255            rCodeStr;    /* result code as a string */
  623.     
  624.     if (rCode && rCode != iPrAbort) {
  625.         if (rCode == fnfErr) {
  626.             utl_StopAlert(noDriverID, nil, 0);
  627.         } else if (rCode == resNotFound) {
  628.             utl_StopAlert(noPrinterID, nil, 0);
  629.         } else  if (rCode == dskFulErr) {
  630.             utl_StopAlert(printDskFullID, nil, 0);
  631.         } else if (rCode == wPrErr) {
  632.             utl_StopAlert(printLockedID, nil, 0);
  633.         } else {
  634.             NumToString(rCode, rCodeStr);
  635.             ParamText(rCodeStr, nil, nil, nil);
  636.             utl_StopAlert(printErrID, nil, 0);
  637.         };
  638.     };
  639. }
  640.  
  641. /*______________________________________________________________________
  642.  
  643.     misc_SetCursor - Set Cursor.
  644. _____________________________________________________________________*/
  645.  
  646.  
  647. void misc_SetCursor (void)
  648.  
  649. {
  650.     if (HelpMode) {
  651.         SetCursor(*HelpCurs);
  652.     } else {
  653.         InitCursor();
  654.     };
  655. }
  656.